import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContractVO, ContractForm, ContractQuery } from '@/api/project/contract/types';

/**
 * 查询合同管理列表
 * @param query
 * @returns {*}
 */

export const listContract = (query?: ContractQuery): AxiosPromise<ContractVO[]> => {
  return request({
    url: '/project/contract/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询合同管理详细
 * @param id
 */
export const getContract = (id: string | number): AxiosPromise<ContractVO> => {
  return request({
    url: '/project/contract/' + id,
    method: 'get'
  });
};

/**
 * 新增合同管理
 * @param data
 */
export const addContract = (data: ContractForm) => {
  return request({
    url: '/project/contract',
    method: 'post',
    data: data
  });
};

/**
 * 修改合同管理
 * @param data
 */
export const updateContract = (data: ContractForm) => {
  return request({
    url: '/project/contract',
    method: 'put',
    data: data
  });
};

/**
 * 删除合同管理
 * @param id
 */
export const delContract = (id: string | number | Array<string | number>) => {
  return request({
    url: '/project/contract/' + id,
    method: 'delete'
  });
};
